.well
    .row
      .col-md-4
        | 采购单号：#{@part_purchase.code}    
      .col-md-4
        | 供应商：#{@part_purchase.supplier.name}
      .col-md-4
        | 备注：#{@part_purchase.note}
    .row
      .col-md-4
        | 创建日期：#{@part_purchase.created_at.strftime('%Y-%m-%d %H:%M:%S')}
      .col-md-4
        | 创建人：#{@part_purchase.user.name}

form method = 'get'
  .row
    .col-md-8
      .panel.panel-default
        .panel-heading
          | 采购配件明细
          = link_to "新增" , new_part_purchase_detail_path(:id=>@part_purchase.id), class: "btn btn-primary btn-xs", style: "margin-left:10px;", :remote=>true

        .panel-body
          .table-responsive
            table.table.table-bordered.table-hover
              tr
                th 配件编号
                th 配件名称
                th 数量
                th 单位
                th 采购单价
                th 小计
                th 操作
              
              -@part_purchase.part_purchase_details.each do |p|
                tr
                  td = p.part.code
                  td = p.part.name
                  td = p.qty
                  td = p.part.unit
                  td = p.part.purchase_price
                  td = p.sub_total
                  td
                    = link_to "删除" , part_purchase_detail_path(:id => p.id), :method => "DELETE", data: {confirm: '一旦删除,将无法恢复,是否删除?'}, class: "btn btn-danger btn-xs"
    .col-md-4
      .panel.panel-default
        .panel-heading
          |新增
        .panel-body
          ==render :partial =>'part_purchase_details/form'

  .well
    == grid(@tasks_grid, show_filters: :always) do |g|  
      -g.column name: '配件编号', attribute: 'code'
      -g.column name: '配件名称', attribute: 'name'
      -g.column name: '配件类别', attribute: 'name', assoc: :part_style
      -g.column name: '车型', attribute: 'car_mo'
      -g.column name: '品牌', attribute: 'brand'
      -g.column name: '单位', attribute: 'unit'
      -g.column name: '库存数', attribute: 'qty', assoc: :inventory
      -g.column name: '备注', attribute: 'note'
      -g.column do |task| link_to('选择', new_part_purchase_detail_path(:id=>@part_purchase.id, :part_id=>task.id), class: "btn btn-primary btn-xs", style: "margin-left:10px;", :remote=>true) end

  button type='submit' class="btn btn-success btn-lg btn-block" name='save' 确定
                
